package com.pls.handlers;

import java.util.ArrayList;

import com.plsContracts.dataContracts.UpdateEmployeeSeatRequest;
import com.plsContracts.dataContracts.UpdateEmployeeSeatResponse;
import com.plsDTO.validation.ValidationError;
import com.plsData.data.EmployeeData;

public class UpdateEmployeeSeatHandler extends
		RequestHandler<UpdateEmployeeSeatResponse, UpdateEmployeeSeatRequest> {

	public UpdateEmployeeSeatHandler(Class<UpdateEmployeeSeatResponse> tResponse) {
		super(tResponse);
		// TODO Auto-generated constructor stub
	}
	
	protected ArrayList<ValidationError> validate(UpdateEmployeeSeatRequest request) {
		ArrayList<ValidationError> errors = new ArrayList<ValidationError>();
		ValidationError valError;
		if (request == null) {
			valError = new ValidationError();
			valError.setMessage("Request is null.");
			valError.setName("NullRequest");
			errors.add(valError);
			return errors;
		}
		if (request.getEmployeeId() == 0) {
			valError = new ValidationError();
			valError.setMessage("Employee Id cannot be null.");
			valError.setName("InvalidInput");
			errors.add(valError);
		}
		if (request.getSeatCode() == null) {
			valError = new ValidationError();
			valError.setMessage("Seat code cannot be null.");
			valError.setName("InvalidInput");
			errors.add(valError);
		}
		

		return errors;
	}
	
	public UpdateEmployeeSeatResponse process(UpdateEmployeeSeatRequest request){
		
		UpdateEmployeeSeatResponse response = new UpdateEmployeeSeatResponse();
		// TODO method
		//call data layer
		EmployeeData empData = new EmployeeData();
		response.setSuccesful(empData.updateEmployeeSeat(request.getEmployeeId(), request.getSeatCode()));
		
		return response;
		
	}

}
